//
//  MyApplicationControl.m
//  WE
//
//  Created by iMacOne on 15/11/28.
//  Copyright © 2015年 UNOHACHA. All rights reserved.
//

#import "MyApplicationControl.h"
#import <Masonry.h>
#import "Size.h"
#import "RequestCell.h"
#import "QuickaboutViewController.h"
@interface MyApplicationControl ()
@property (nonatomic, strong)UISegmentedControl * segmentControl;
@property (nonatomic, strong)UITableView * leftTableView;
@property (nonatomic, strong)UITableView * rightTableView;

@end

@implementation MyApplicationControl

- (void)viewWillAppear:(BOOL)animated
{
    self.navigationController.navigationBar.hidden = NO;
    
}

- (void)viewDidLoad
{
    self.navigationItem.title = @"我的申请";
    self.view.backgroundColor = [UIColor whiteColor];
    
    self.segmentControl  = [[UISegmentedControl alloc] initWithItems:@[@"加号申请",@"快约申请"]];
    [self.view addSubview:self.segmentControl];
    
    _segmentControl.selectedSegmentIndex = 0;
    [self creatNoDataView1];
    [_segmentControl setTintColor:[UIColor blueColor]];
    [_segmentControl addTarget:self action:@selector(doClick:) forControlEvents:UIControlEventValueChanged];
    
    [self.segmentControl mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).offset(40);
        make.centerX.equalTo(self.view);
        make.top.equalTo(self.view).offset(80);
        make.height.offset(30);
    }];
//    [self.view addSubview:self.leftTableView];
    
    
    
    
}
- (void)creatNoDataView1
{
    UIView * aView = [UIView new];
    [self.view addSubview:aView];
    aView.backgroundColor = GRAYCOLOR;
    [aView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.segmentControl.mas_bottom).offset(20);
        make.size.mas_equalTo(CGSizeMake(WindowWidth, WindowHeight));
        
    }];
    
    UILabel * lbl = [UILabel new];
    [aView addSubview:lbl];
    //    lbl.backgroundColor = DEBUG_CLOLR;
    lbl.text = @"暂无加号申请";
    lbl.font = FONT(14);
    lbl.textColor = [UIColor grayColor];
    //    lbl.textAlignment = NSTextAlignmentCenter;
    [lbl mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(aView.mas_top).with.offset(20);
        make.centerX.equalTo(self.view);
        make.height.mas_equalTo(20);
    }];
}
- (void)creatNoDataView2
{
    UIView * aView = [UIView new];
    [self.view addSubview:aView];
    aView.backgroundColor = GRAYCOLOR;
    [aView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.segmentControl.mas_bottom).offset(20);
        make.size.mas_equalTo(CGSizeMake(WindowWidth, WindowHeight));
        
    }];
    
    UILabel * lbl = [UILabel new];
    [aView addSubview:lbl];
    //    lbl.backgroundColor = DEBUG_CLOLR;
    lbl.text = @"您还没申请过微医快约";
    lbl.font = FONT(14);
    lbl.textColor = [UIColor grayColor];
    //    lbl.textAlignment = NSTextAlignmentCenter;
    [lbl mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(aView.mas_top).with.offset(20);
        make.centerX.equalTo(self.view);
        make.height.mas_equalTo(20);
    }];
    
    UILabel * lbl1 = [UILabel new];
    [aView addSubview:lbl1];
    //    lbl.backgroundColor = DEBUG_CLOLR;
    lbl1.text = @"生病了不知道去哪个医院挂个科? 这种病哪位专家更擅长? 专家号总是约不到?";
    lbl1.font = FONT(14);
    lbl1.numberOfLines = 0;
    lbl1.textColor = [UIColor grayColor];
    //    lbl.textAlignment = NSTextAlignmentCenter;
    [lbl1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(lbl.mas_bottom).with.offset(20);
        make.centerX.equalTo(self.view);
        make.left.equalTo(self.view).offset(20);
//        make.height.mas_equalTo(20);
    }];

    UILabel * lbl2 = [UILabel new];
    [aView addSubview:lbl2];
    //    lbl.backgroundColor = DEBUG_CLOLR;
    lbl2.text = @"用微医快约, 看病没烦恼!";
    lbl2.font = FONT(14);
    lbl2.textColor = [UIColor grayColor];
    //    lbl.textAlignment = NSTextAlignmentCenter;
    [lbl2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(lbl1.mas_bottom).with.offset(10);
//        make.centerX.equalTo(self.view);
        make.left.equalTo(lbl1.mas_left);
        make.height.mas_equalTo(20);
    }];

    UILabel * lbl3 = [UILabel new];
    [aView addSubview:lbl3];
    //    lbl.backgroundColor = DEBUG_CLOLR;
    lbl3.text = @"核心优势: 5000组专家团队, 800万三甲医院号源, 精准匹配, 快速响应, 直达名医";
    lbl3.font = FONT(14);
    lbl3.numberOfLines = 0;
    lbl3.textColor = [UIColor grayColor];
    //    lbl.textAlignment = NSTextAlignmentCenter;
    [lbl3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(lbl2.mas_bottom).with.offset(10);
//        make.centerX.equalTo(self.view);
        make.left.equalTo(lbl1.mas_left);
        make.centerX.equalTo(self.view);

        //        make.height.mas_equalTo(20);
    }];
    
    UIButton * btn = [UIButton new];
    [aView addSubview:btn];
    btn.backgroundColor = [UIColor blueColor];
    [btn setTitle:@"我要申请" forState:UIControlStateNormal];
    [btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [btn addTarget:self action:@selector(doClickbtn:) forControlEvents:UIControlEventTouchUpInside];
    btn.titleLabel.font = FONT(14);
    [btn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(lbl3.mas_bottom).offset(15);
        make.left.equalTo(lbl3.mas_left);
        make.centerX.equalTo(self.view);
        make.size.height.offset(40);
    }];

}
- (void)doClickbtn:(UIButton *)btn
{
    [self.navigationController pushViewController:[[QuickaboutViewController alloc] init] animated:YES];
}
- (void)doClick:(UISegmentedControl *)segment
{
    if (segment.selectedSegmentIndex == 0) {
        [self creatNoDataView1];
//        [self.leftTableView reloadData];
    }else if (segment.selectedSegmentIndex == 1){
//        [self.leftTableView reloadData];
        [self creatNoDataView2];

    }
}
//- (void)creatTableView
//{
//    self.leftTableView = [UITableView new];
//    [self.leftTableView mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.equalTo(self.segmentControl.mas_bottom).offset(5);
//        
//        make.size.mas_equalTo(CGSizeMake(300, 400));
//        make.left.equalTo(self.view).offset(0);
//    }];
//    _leftTableView.dataSource = self;
//    _leftTableView.delegate = self;
//    _leftTableView.rowHeight = 45;
//    _leftTableView.backgroundColor = [UIColor yellowColor];
//    
//}
- (UITableView *)leftTableView
{
    if (_leftTableView == nil) {
        self.leftTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 125 ,WindowWidth , WindowHeight-120 ) style:UITableViewStylePlain];
      
        _leftTableView.dataSource = self;
        _leftTableView.delegate = self;
        _leftTableView.rowHeight = WindowHeight-120 ;
        _leftTableView.scrollEnabled = NO;
//        _leftTableView.backgroundColor = [UIColor yellowColor];
        
    }
    return _leftTableView;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (self.segmentControl.selectedSegmentIndex == 0) {
        
        static NSString * cellIdentifier = @"cellOne";
        UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
        if (cell == nil) {
            cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            cell.backgroundColor = GRAYCOLOR;
        }
        return cell;
    }
    static NSString * cellIdentifier = @"cellTwo";
    RequestCell * cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    if (cell == nil) {
        cell = [[RequestCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.backgroundColor = GRAYCOLOR;
//        cell.textLabel.text = @"hahahaha";
    }
    return cell;
}
@end
